<#
 #   It is recommended to test the script on a local machine for its purpose and effects. 
 #   ManageEngine Endpoint Central will not be responsible for any 
 #   damage/loss to the data/setup based on the behavior of the script.

 #   Description: Script is designed to fetch scheduled tasks running under a currently logged on user
 #   Configuration Type - USER
#>

# Get the currently logged-in user from the environment variable
$currentUsername = $env:USERNAME

# Display the currently logged-in user
Write-Host "Currently logged-on user: $currentUsername"

# Fetch and display only scheduled tasks for the currently logged-in user
Get-ScheduledTask | Where-Object { $_.Principal.UserId -eq $currentUsername } | ForEach-Object {
    Write-Output "Task Name: $($_.TaskName), State: $($_.State)"
}